package com.itheima.dao;


import com.itheima.pojo.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {
    //查询全部
    @Select("select * from tbl_book")
    List<Book> findAll();

    //根据id查询
    @Select("select * from tbl_book where id = #{id}")
    Book findById(Integer id);

    //删除数据
    @Delete("delete from tbl_book where id = #{id}")
    int deleteById(Integer id);

    //添加数据
    @Insert("insert into tbl_book values(null,#{type},#{name},#{description})")
    int addBook(Book book);

    //更新数据
    @Update("update tbl_book set type=#{type},name=#{name},description=#{description} where id = #{id}")
    int updateBook(Book book);
}
